11. Exercise: Data Binding

Data Binding

In this exercise, you will get to link your UI with actual data using data-binding

Exercise Code

Exercise: T11.02-Exercise-DataBinding

Data Binding

Now it's your turn to implement the data binding classes and link the UI components with actual data values.

SOLUTION:
  • Enable Data Binding in your application
  • Use <layout> as the root tag for activity_main
  • Create a data binding instance of type ActivityMainBinding and set the Content View to the activity_main
  • Load a BoardingPassInfo object with some data
  • Use the ActivityMainBinding object to set all textViews with the data from BoardingPassInfo